#include <iostream>

using namespace std;

#define MAX_NUMBER_LENGTH 6
static int gPath[MAX_NUMBER_LENGTH][MAX_NUMBER_LENGTH]= {
	{0 , 0, 0, 0, 1, 1},  
    {1,  1, 0, 0, 1, 0},  
    {0 , 1, 1, 1, 1, 0},  
    {0 , 0, 1, 0, 1, 2},  
    {0 , 0, 1, 0, 1, 0},  
    {0 , 0, 1, 1, 1, 0}  
};

static int gValue[MAX_NUMBER_LENGTH][MAX_NUMBER_LENGTH] = {0};

int check_pos_valid(int x, int y)
{
	if(x<0 || x>=MAX_NUMBER_LENGTH || y<0 || y>= MAX_NUMBER_LENGTH)
		return 0;
	if(0 == gPath[x][y])
		return 0;

	if('#' == gValue[x][y])
		return 0;

	return 1;
}

int find_path(int x, int y)
{
	if(check_pos_valid(x,y))
	{
		if(2 == gPath[x][y]){
			gValue[x][y] = '#';
			return 1;
		}

		gValue[x][y] = '#';
		if(find_path(x,y-1))
			return 1;
		if(find_path(x-1, y))
			return 1;
		if(find_path(x, y+1))
			return 1;
		if(find_path(x+1, y))
			return 1;
		gValue[x][y] = 0;
		return 0;
	}

	return 0;
}

void find_path(int x, int y)
{
	if(check_pos_valid(x,y))
	{
		if(2 == gPath[x][y]){
			gValue[x][y] = '#';
			print_path();
			gValue[x][y] = 0;
			return ;
		}
		
	}
}


int main()
{
    cout << "Hello world!" << endl;
    return 0;
}
